home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15691 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Can a function return a array of pointers? a.s.a.p.
  5. Date: 20 Apr 1996 18:16:36 -0700
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4lc29kINNdkd@keats.ugrad.cs.ubc.ca>
  8. References: <4lalvn$536@badger.wmin.ac.uk>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <4lalvn$536@badger.wmin.ac.uk>,
  12. Idoia Lertxundi  <gsoec@wmin.ac.uk> wrote:
  13.  >My question is Can a function return a array of pointers? 
  14.  >
  15.  >It seems that the compiler does not like the following:
  16.  >
  17.  >static char[] *ReadCodes(FILE *fptr, char *codes_array_p[MAX_CODES], char
  18.  >*codes[MAX_CODES])
  19.  
  20. In addition to Dan Pop's comment (arrays can't be passed or returned), the
  21. above is not the proper syntax for declaring an (impossible) function that is
  22. to return an array. Cast-style type expressions are not suitable for
  23. declarations. It's easy to make the mistake, though:
  24.  
  25.     static char readcodes(int arg)[3]
  26.  
  27.     {
  28.         /* bogus function definition for returning
  29.            an array of 3 char */
  30.     }
  31.  
  32.  
  33.  >even [MAX_CODES] gives an error, therefore how can I represent a function
  34.  >returning a type array of pointers?
  35.  
  36. As above. And no compiler for the C language will take it.
  37.